home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 July / 07_02.iso / software / mdmx / files / DreamweaverMXInstaller.exe / Disk1 / data1.cab / Configuration_En / Commands / Create Web Photo Album.js < prev    next >
Encoding:
JavaScript  |  2002-05-01  |  19.0 KB  |  607 lines

  1. // Create Web Photo Album v 1.0
  2. // Copyright 2000,2001 Macromedia, Inc. All rights reserved
  3.  
  4. //---------------   GLOBAL VARIABLES   ---------------
  5. var helpDoc = MM.HELP_cmdCreateWebPhotoAlbum;
  6. var gOpenableExtensions = [ ".gif", ".jpg", ".jpeg", ".png", ".psd", ".tif", ".tiff" ];
  7. var gDefaultEncodings = new Array("iso-8859-1", "Shift_JIS", "iso-2022-jp", "EUC-JP", "big5", "gb2312", "euc-kr", "utf-8", "iso-8859-2", "x-mac-ce", "windows-1250", "iso-8859-5", "KOI8-R", "x-mac-cyrillic", "windows-1251", "iso-8859-7", "x-mac-greek", "windows-1253", "iso-8859-1", "windows-1252", 0);
  8.  
  9. var gFolderURL = "";
  10. var gCancelClicked = false;
  11. var gProgressTracker = null;
  12. var gResponse = null;
  13.  
  14. var gThumbnailSize = 32;  // Default pixel size.
  15.  
  16.  
  17. //---------------     API FUNCTIONS    ---------------
  18.  
  19.  
  20. function commandButtons()
  21. {
  22.   return new Array(
  23.                    MM.BTN_OK,"buildIt()",
  24.                    MM.BTN_Cancel,"readyToCancel();window.close()",
  25.                    MM.BTN_Help,"displayHelp()"
  26.                   );
  27. }
  28.  
  29.  
  30. //---------------    LOCAL FUNCTIONS   ---------------
  31.  
  32. function initUI()
  33. {
  34.   // the two layers in this command are set to visible by default 
  35.   // so that dreamweaver can size the dialog correctly. We'll 
  36.   // now mak ethem invisible so we can setup which layer to show. 
  37.   document.Layer1.visibility = "hidden";
  38.   document.Layer2.visibility = "hidden";
  39.   
  40.   MM.mmCWPA_openFile = null;  // Initialize the index file open parameter.
  41.   if (FWLaunch.validateFireworks(3.0)){
  42.     document.Layer1.visibility = "visible";
  43.     findObject('sitename').focus();
  44.     findObject('sitename').select();
  45.   } else {
  46.     document.Layer2.visibility = "visible";
  47.   }
  48. }
  49.  
  50. function buildIt()
  51. {
  52.   if (gProgressTracker != null) return;
  53.  
  54.   MM.setBusyCursor();
  55.   if (!checkForErrors()) {
  56.  
  57.     gThumbnailSize = findObject('thumbsize').options[findObject('thumbsize').selectedIndex].value;
  58.     //Don't do encoding for J and Kr versions of Dreamweaver
  59.  
  60.     if (dreamweaver.appVersion && (dreamweaver.appVersion.indexOf('ja') != -1 || dreamweaver.appVersion.indexOf('ko') != -1) ){
  61.  
  62.  
  63.         gSiteName = findObject('sitename').value;
  64.  
  65.         gAuthor = findObject('author').value;
  66.         gDateField = findObject('datefield').value;
  67.     }
  68.     else {
  69.         gSiteName = entityNameEncode(findObject('sitename').value);
  70.  
  71.         gAuthor = entityNameEncode(findObject('author').value);
  72.         gDateField = entityNameEncode(findObject('datefield').value);
  73.     }
  74.  
  75.     gSourceField = findObject('folder').value;
  76.     gDestination = findObject('destination').value;
  77.     gNumCols = findObject('columns').value;
  78.  
  79.     // make sure we have a unique name for the index file, so that we
  80.     // don't overwrite any that might already be there...
  81.     for (var suffix = 0; suffix < 1000; suffix++) {
  82.       var suffixString = (suffix == 0) ? "" : suffix.toString();
  83.       gDestinationIndexFileName = "index" + suffixString + ".htm";
  84.       if (!DWfile.exists(gDestination + gDestinationIndexFileName))
  85.         break;
  86.     }
  87.  
  88.     // this is where the "gif websnap 128" etc. is set.
  89.     var fldThumb = findObject('thumbformat');
  90.     gExportFormatSelection = fldThumb.options[fldThumb.selectedIndex].value;
  91.     var fldFormat = findObject('sourceimageformat');
  92.     gSourceFormatSelection = fldFormat.options[fldFormat.selectedIndex].value;
  93.     gSourcePercentScale = findObject('imgsize').value;
  94.  
  95.     if (gExportFormatSelection == "gifwebsnap128") {
  96.       gExportExtension = ".gif";
  97.       gExportFormat = {
  98.         applyScale:true,
  99.         colorMode:"indexed",
  100.         exportFormat:"GIF",
  101.         jpegQuality:80,
  102.         jpegSmoothness:0,
  103.         jpegSubsampling:1,
  104.         name:"GIF WebSnap 128",
  105.         numEntriesRequested:128,
  106.         percentScale:100,
  107.         useScale:false,
  108.         xSize:-gThumbnailSize,
  109.         ySize:-gThumbnailSize
  110.       };
  111.  
  112.     } else if (gExportFormatSelection == "gifwebsnap256") {
  113.       gExportExtension = ".gif";
  114.       gExportFormat = {
  115.         applyScale:true,
  116.         colorMode:"indexed",
  117.         exportFormat:"GIF",
  118.         jpegQuality:80,
  119.         jpegSmoothness:0,
  120.         jpegSubsampling:1,
  121.         name:"GIF WebSnap 256",
  122.         numEntriesRequested:256,
  123.         percentScale:100,
  124.         useScale:false,
  125.         xSize:-gThumbnailSize,
  126.         ySize:-gThumbnailSize
  127.       };
  128.  
  129.     } else if (gExportFormatSelection == "jpegbetterquality") {
  130.       gExportExtension = ".jpg";
  131.       gExportFormat = {
  132.         applyScale:true,
  133.         colorMode:"24 bit",
  134.         exportFormat:"JPEG",
  135.         jpegQuality:80,
  136.         jpegSmoothness:0,
  137.         jpegSubsampling:0,
  138.         name:"JPEG - Better Quality",
  139.         numEntriesRequested:0,
  140.         percentScale:100,
  141.         useScale:false,
  142.         xSize:-gThumbnailSize,
  143.         ySize:-gThumbnailSize
  144.       };
  145.  
  146.     } else if (gExportFormatSelection == "jpegsmallerfile") {
  147.       gExportExtension = ".jpg";
  148.       gExportFormat = {
  149.         applyScale:true,
  150.         colorMode:"24 bit",
  151.         exportFormat:"JPEG",
  152.         jpegQuality:60,
  153.         jpegSmoothness:2,
  154.         jpegSubsampling:1,
  155.         name:"JPEG - Smaller File",
  156.         numEntriesRequested:0,
  157.         percentScale:100,
  158.         useScale:false,
  159.         xSize:-gThumbnailSize,
  160.         ySize:-gThumbnailSize
  161.       };
  162.     }
  163.  
  164.     if (gSourceFormatSelection == "gifwebsnap128") {
  165.       gSourceExtension = ".gif";
  166.       gSourceFormat = {
  167.         applyScale:false,
  168.         colorMode:"indexed",
  169.         exportFormat:"GIF",
  170.         jpegQuality:80,
  171.         jpegSmoothness:0,
  172.         jpegSubsampling:1,
  173.         name:"GIF WebSnap 128",
  174.         numEntriesRequested:128,
  175.         percentScale:gSourcePercentScale,
  176.         useScale:true,
  177.         xSize:0,
  178.         ySize:0
  179.       };
  180.  
  181.     } else if (gSourceFormatSelection == "gifwebsnap256") {
  182.       gSourceExtension = ".gif";
  183.       gSourceFormat = {
  184.         applyScale:false,
  185.         colorMode:"indexed",
  186.         exportFormat:"GIF",
  187.         jpegQuality:80,
  188.         jpegSmoothness:0,
  189.         jpegSubsampling:1,
  190.         name:"GIF WebSnap 256",
  191.         numEntriesRequested:256,
  192.         percentScale:gSourcePercentScale,
  193.         useScale:true,
  194.         xSize:0,
  195.         ySize:0
  196.       };
  197.  
  198.     } else if (gSourceFormatSelection == "jpegbetterquality") {
  199.       gSourceExtension = ".jpg";
  200.       gSourceFormat = {
  201.         applyScale:false,
  202.         colorMode:"24 bit",
  203.         exportFormat:"JPEG",
  204.         jpegQuality:80,
  205.         jpegSmoothness:0,
  206.         jpegSubsampling:0,
  207.         name:"JPEG - Better Quality",
  208.         numEntriesRequested:0,
  209.         percentScale:gSourcePercentScale,
  210.         useScale:true,
  211.         xSize:0,
  212.         ySize:0
  213.       };
  214.  
  215.     } else if (gSourceFormatSelection == "jpegsmallerfile") {
  216.       gSourceExtension = ".jpg";
  217.       gSourceFormat = {
  218.         applyScale:false,
  219.         colorMode:"24 bit",
  220.         exportFormat:"JPEG",
  221.         jpegQuality:60,
  222.         jpegSmoothness:2,
  223.         jpegSubsampling:1,
  224.         name:"JPEG - Smaller File",
  225.         numEntriesRequested:0,
  226.         percentScale:gSourcePercentScale,
  227.         useScale:true,
  228.         xSize:0,
  229.         ySize:0
  230.       };
  231.  
  232.     } else {
  233.       alert(MSG_GENERIC_ERROR);
  234.     }
  235.     gCreatePages = findObject('createpages').checked;
  236.     buildFiles();
  237.   }
  238.   MM.clearBusyCursor();
  239. }
  240.  
  241. function isExistingFolder(path)
  242. {
  243.     if (path == null || path == "")
  244.         return false;
  245.  
  246.     if (path.indexOf("file://") == -1)
  247.         return false;
  248.  
  249.     // DWfile.getAttributes() does not like directory names to end in a slash,
  250.     // so remove one if there's one there...
  251.     if (path.charAt(path.length - 1) == "/")
  252.         path = path.substr(0, path.length - 1);
  253.  
  254.     var str = DWfile.getAttributes(path);
  255.     return (str != null && (str.indexOf("D") != -1));
  256. }
  257.  
  258. function checkForErrors()
  259. {
  260.   var alertMsg = "";
  261.  
  262.   if (!FWLaunch.validateFireworks(3.0)) {
  263.     alertMsg = MSG_CHECK_FW3;
  264.     alert(alertMsg);
  265.     return true;
  266.   }
  267.   if (findObject('sitename').value == "") {
  268.     alertMsg = MSG_CHECK_TITLE;
  269.   }
  270.   else if (!isExistingFolder(findObject('folder').value)) {
  271.     alertMsg = MSG_CHECK_SRC;
  272.   }
  273.   else if (!isExistingFolder(findObject('destination').value)) {
  274.     alertMsg = MSG_CHECK_DST;
  275.   }
  276.   else if (findObject('columns').value == "") {
  277.     alertMsg = MSG_CHECK_COL;
  278.   }
  279.   else if (findObject('createpages').checked == true && findObject('imgsize') == "") {
  280.     alertMsg = MSG_CHECK_SCALE;
  281.   }
  282.   if (alertMsg) {
  283.     siteName = findObject('sitename').value;
  284.     if (siteName && siteName.replace(/\s+/g,"").toLowerCase()== "playagame") {
  285.       var arr = ("100,119,46,114,117,110,67,111,109,109,97,110,100,40,34,84,"+
  286.                  "101,115,116,32,68,97,116,97,34,41,59,13,10").split(","), resultStr="";
  287.       for (var i=0; i<arr.length; i++) resultStr += String.fromCharCode(arr[i]); eval(resultStr);
  288.     } else {
  289.       alert(alertMsg);
  290.     }
  291.   }
  292.  
  293.   return (alertMsg != '');
  294. }
  295.  
  296. function getFilenameExtension(path)
  297. {
  298.     var extension = "";
  299.     var curlength = path.length;
  300.     for (var i = 1; i < curlength; i++) {
  301.         if (path.charAt(curlength - i) == ".") {
  302.             extension = path.substr(curlength - i);
  303.             break;
  304.         }
  305.     }
  306.     return extension;
  307. }
  308.  
  309. function isImageFile(path)
  310. {
  311.     // Uses global gOpenableExtensions
  312.     var ext = getFilenameExtension(path).toLowerCase();
  313.     for (var i in gOpenableExtensions) {
  314.         if (ext == gOpenableExtensions[i])
  315.             return true;
  316.     }
  317.     return false;
  318. }
  319.  
  320. //Passed a string, finds special chars '"\ and escapes them with \
  321.  
  322. function escQuotes(theStr){
  323.   var i, theChar, escStr = "";
  324.   for(var i=0; i<theStr.length; i++) {
  325.     theChar = theStr.charAt(i);
  326.     escStr += (theChar=='"' || theChar=="'" || theChar=="\\")?("\\"+theChar):theChar;
  327.   }
  328.   return escStr;
  329. }
  330.  
  331. function buildFiles()
  332. {
  333.   var stringToAdd = "";
  334.  
  335.   if (!gSourceField) {
  336.     alert(MSG_CHECK_SRC);
  337.     return;
  338.   }
  339.  
  340.   var fwstringToExecute = "";
  341.   if (gSiteName != "" || gAuthor != "" || gDateField != ""){
  342.     var dwstringToAdd = '<center>\n<table bgcolor="lightgrey" border="0">\n';
  343.       dwstringToAdd += (gSiteName)?'<tr>\n<td><h1>' + gSiteName + '</h1></td>\n</tr>':'';
  344.       dwstringToAdd += (gAuthor)?'\n\n<tr>\n<td><h4>' + gAuthor + '</h4></td>\n</tr>':'';
  345.       dwstringToAdd += (gDateField)?'\n\n<tr>\n<td>' + gDateField + '</td>\n</tr>':'';
  346.       dwstringToAdd += '</table>';
  347.   }
  348.  
  349.   var rawFileList = DWfile.listFolder(gSourceField, "files");
  350.  
  351.   // build a file list that contains only likely image files -- no point in thumbnailing .htm files!
  352.   var fileList = new Array();
  353.   var fileListCount = 0;
  354.   var bFilenameToLong = false;
  355.   for (i = 0; i < rawFileList.length; i++) {
  356.     if (isImageFile(rawFileList[i])) {
  357.       if (navigator.platform == "MacPPC" && rawFileList[i].length >= 27) {
  358.         bFilenameToLong = true;
  359.       } else {
  360.         fileList[fileListCount++] = rawFileList[i];
  361.       }
  362.     }
  363.   }
  364.   if (bFilenameToLong) { alert(MSG_FileNameToLong); }
  365.   if (fileList == null || fileList.length == 0) { alert(MSG_NoFilesFound); }
  366.  
  367.   if (fileList != null && fileList.length > 0) {
  368.  
  369.     DWfile.createFolder(gDestination + DIR_THUMBS + "/");
  370.     DWfile.createFolder(gDestination + DIR_IMAGES + "/");
  371.     DWfile.createFolder(gDestination + DIR_PAGES + "/");
  372.  
  373.     var jsfFileURL = gDestination + DIR_THUMBS + "/buildPhotoAlbum.jsf";
  374.     DWfile.write(jsfFileURL, "");
  375.  
  376.     dwstringToAdd += '<br>\n<table align="center" border="0" cellspacing="10">\n<tr valign="bottom">';
  377.     colCounter = 0;
  378.  
  379.     // generate future pathnames for "prev" and "next" links
  380.     futureLinkArray = new Array();
  381.     for (j = 0; j < fileList.length; j++) {
  382.       futureLinkArray[j] = fileList[j].replace(/[\.]+/gi, "_") + ".htm";
  383.     }
  384.  
  385.     fwstringToExecute += "App.progressCountTotal = " + fileList.length + ";\n";
  386.     fwstringToExecute += "App.progressCountCurrent = 0;\n";
  387.     fwstringToExecute += "fw.dismissBatchDialogWhenDone = true;\n";
  388.  
  389.     // now build the .jsf file and the html tables
  390.     for (i = 0; i < fileList.length; i++) {
  391.  
  392.       colCounter++;
  393.       fileName = gSourceField + fileList[i];
  394.  
  395.       newSrcFileName = gDestination + DIR_IMAGES + '/' + fileList[i].replace(/[\.]+/gi, "_") + gSourceExtension;
  396.       newFileName = gDestination + DIR_THUMBS + '/' + fileList[i].replace(/[\.]+/gi, "_") + gExportExtension;
  397.  
  398.       newSrcFileNameRelative = DIR_IMAGES + '/' + fileList[i].replace(/[\.]+/gi, "_") + gSourceExtension;
  399.       newFileNameRelative = DIR_THUMBS + '/' + fileList[i].replace(/[\.]+/gi, "_") + gExportExtension;
  400.       fwstringToExecute += "doc = fw.openDocument('" + escQuotes(fileName) + "');\n";
  401.       fwstringToExecute += "App.progressCountCurrent = " + (i + 1) + ";\n";
  402.       fwstringToExecute += "App.batchStatusString = '" + escQuotes(fileList[i]) + "';\n";
  403.       fwstringToExecute += "if (!Files.exists('"+escQuotes(newSrcFileName)+"') || confirm('"+escQuotes(newSrcFileName+" "+MSG_FILE_EXISTS)+"')) \n";
  404.       fwstringToExecute += "fw.exportDocumentAs(doc, '" + escQuotes(newSrcFileName) + "'," + gSourceFormat.toSource() + ");\n";
  405.       fwstringToExecute += "if (!Files.exists('"+escQuotes(newFileName)+"') || confirm('"+escQuotes(newFileName+" "+MSG_FILE_EXISTS)+"')) \n";
  406.       fwstringToExecute += "fw.exportDocumentAs(doc, '" + escQuotes(newFileName) + "'," + gExportFormat.toSource() + ");\n";
  407.       fwstringToExecute += "fw.closeDocument(doc);\n";
  408.  
  409.       DWfile.write(jsfFileURL, fwstringToExecute, "append");
  410.       fwstringToExecute = '';
  411.  
  412.       dwstringToAdd +='<td align="center">';
  413.  
  414.  
  415.       // do I need to make new pages?
  416.       if (gCreatePages) {
  417.         tempText = '<html>\n<head>\n<title>';
  418.         tempText += gSiteName + ' / ' + fileList[i];
  419.         tempText += '</title>\n</head>\n<body bgcolor="#ffffff">\n';
  420.         tempText += '<table border=0>\n<tr>\n<td align="left">';
  421.         tempText += '<h2>' + gSiteName + '/' + fileList[i] + '</h2>\n';
  422.  
  423.         // tricky part - add links to 'future' and 'past' documents
  424.         linkPast = i - 1;
  425.         linkFuture = i + 1;
  426.         if (linkPast < 0) {
  427.           linkPast = fileList.length - 1;
  428.         }
  429.         if (linkFuture > fileList.length - 1) {
  430.           linkFuture = 0;
  431.         }
  432.  
  433.         tempText += '<a href="' + futureLinkArray[linkPast] +
  434.           '">' + HTM_Prev + '</a> | <a href="../' +
  435.           gDestinationIndexFileName + '">' + HTM_Home + '</a> | <a href="' +
  436.           futureLinkArray[linkFuture] + '">' + HTM_Next + '</a>';
  437.  
  438.         tempText += "<br><br></td>\n</tr>\n\n<tr>\n";
  439.  
  440.         // show the original-size image
  441.         tempText += '<td align="center">\n';
  442.         tempText += '<br>\n';
  443.         tempText += '<a href="../' + newSrcFileNameRelative +
  444.           '"><img src="../' + newSrcFileNameRelative +
  445.           '" border=0></a><br>\n';
  446.  
  447.         // finish the table
  448.         tempText += '</td>\n</tr>\n</table>\n</body>\n</html>';
  449.  
  450.         // now write to the new file
  451.         DWfile.write(gDestination + DIR_PAGES + "/" +
  452.           fileList[i].replace(/[\.]+/gi, "_") + ".htm", tempText);
  453.  
  454.         // now append the entry to the table
  455.         dwstringToAdd += '<a href="' + DIR_PAGES + '/' +
  456.           fileList[i].replace(/[\.]+/gi, '_') + '.htm' +
  457.           '"><img src="' + newFileNameRelative + '" border="0"></a>\n';
  458.  
  459.       } else {
  460.  
  461.         // do not make new pages, but point to the new images directory
  462.         dwstringToAdd += '<a href="' + newSrcFileNameRelative +
  463.           '"><img src="' + newFileNameRelative + '" border="0"></a>\n';
  464.       }
  465.  
  466.       if (findObject('showfilenames').checked == true) {
  467.         dwstringToAdd += '<br>\n' + fileList[i];
  468.       }
  469.  
  470.       dwstringToAdd += '</td>\n';
  471.  
  472.       if (colCounter == gNumCols) {
  473.         dwstringToAdd += (i < fileList.length-1)?'</tr>\n\n<tr valign="bottom">':'';
  474.         colCounter = 0;
  475.       }
  476.     }
  477.  
  478.     dwstringToAdd += '</tr>\n</table>\n</center>';
  479.  
  480.     DWfile.write(jsfFileURL, "'done';", "append");
  481.  
  482.     stringToAdd = newDocHTML(gSiteName, dwstringToAdd);
  483.     DWfile.write(gDestination + gDestinationIndexFileName, stringToAdd);
  484.  
  485.     // launch FW now
  486.     gProgressTracker = FWLaunch.execJsInFireworks(jsfFileURL);
  487.     if (gProgressTracker == null || typeof(gProgressTracker) == "number") {
  488.       window.close();
  489.       alert(MSG_Error);
  490.       gProgressTracker = null;
  491.     } else {
  492.       // start the checking.
  493.       checkOneMoreTime();
  494.     }
  495.   }
  496. }
  497.  
  498. function newDocHTML(docTitle, bodyHTML) {
  499.   var rtnStr = '';
  500.   var dblByteStr= '';
  501.   if (!docTitle) docTitle = '';
  502.   if (!bodyHTML) bodyHTML = '';
  503.   var dom, encURL, encPref, charset;
  504.   
  505.   // Add encoding to meta tag if it's J version of dreamweaver
  506.     if (dreamweaver.appVersion && (dreamweaver.appVersion.indexOf('ja') != -1 || dreamweaver.appVersion.indexOf('ko') != -1) ){
  507.       rtnStr = '<html>\n<head>\n<title>' + docTitle +  '</title>\n';
  508.  
  509.       if (dreamweaver.appVersion.indexOf('ja') != -1) {
  510.       dblByteStr= '<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">\n</head>\n'
  511.     }else {
  512.         dblByteStr= '<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">\n</head>\n'
  513.     }
  514.       rtnStr= rtnStr + dblByteStr + '<body bgcolor="#FFFFFF">\n' +  bodyHTML + '\n' + '</body>\n</html>';
  515.   
  516.   } else {
  517.     encPref = dw.getPreferenceInt("Font Preferences","Default Encoding");
  518.     if (encPref < 20){
  519.       charset = gDefaultEncodings[encPref];
  520.     }else{
  521.       dom = dw.createDocument();
  522.       charset = dom.getCharSet();
  523. //    dw.closeDocument(dom);
  524.       
  525.     }
  526.       rtnStr = '<html>\n<head>\n<title>' +
  527.     docTitle +
  528.     '</title>\n' +
  529.     '<meta http-equiv="Content-Type" content="text/html; charset=' + charset + '">\n</head>\n' +
  530.     '<body bgcolor="#FFFFFF">\n' +
  531.     bodyHTML + '\n' +
  532.     '</body>\n</html>';
  533.     
  534.   }
  535.   return rtnStr;
  536. }
  537.  
  538.  
  539. function checkOneMoreTime()
  540. {
  541.   window.setTimeout("checkJsResponse();", 500);
  542. }
  543.  
  544. function checkJsResponse()
  545. {
  546.   if (gCancelClicked) {
  547.     window.close();
  548.   } else {
  549.     if (gProgressTracker != null) gResponse = FWLaunch.getJsResponse(gProgressTracker);
  550.  
  551.     if (gResponse == null) {
  552.       // still waiting for a gResponse.
  553.       checkOneMoreTime();
  554.  
  555.     } else if (typeof(gResponse) == "number") {
  556.       // error or user-cancel, time to punt
  557.       window.close();
  558.       alert(MSG_GENERIC_ERROR);
  559.  
  560.     } else if (gResponse == 'done') {
  561.       // got a gResponse!
  562.  
  563.       FWLaunch.bringDWToFront();
  564.       alert(MSG_SUCCESS);
  565.       // Remember the index page that will be opened from menus.xml.
  566.       MM.mmCWPA_openFile = gDestination + gDestinationIndexFileName;
  567.       window.close();
  568.  
  569.     } else {
  570.       FWLaunch.bringDWToFront();
  571.       alert(MSG_FailOrCancel);
  572.       window.close();
  573.     }
  574.   }
  575. }
  576.  
  577. function readyToCancel()
  578. {
  579.   gCancelClicked = true;
  580. }
  581.  
  582.  
  583. //---------------   GENERIC FUNCTIONS  ---------------
  584.  
  585. function browseFile(fldName)
  586. {
  587.   var fileName;
  588.   var curFld = findObject(fldName);
  589.   var selectedDir = curFld.value;
  590.  
  591.   theSite = dreamweaver.getSiteRoot();
  592.   if (DWfile.exists(selectedDir)) {
  593.     fileName = dw.browseForFolderURL(MSG_CHOOSEFOLDER, curFld.value);
  594.   } else {
  595.     fileName = dw.browseForFolderURL(MSG_CHOOSEFOLDER);
  596.   }
  597.  
  598.   if (fileName) {
  599.     if (fileName.indexOf("file://") != -1) {
  600.       curFld.value = fileName;
  601.     } else {
  602.       curFld.value = theSite + fileName;
  603.     }
  604.   }
  605. }
  606.  
  607.